package cn.gailvlun.gll.presentation.apartment.task.adapter;

import android.content.Context;

import com.github.markzhai.recyclerview.SingleTypeAdapter;

import java.util.ArrayList;
import java.util.List;

import cn.gailvlun.gll.R;
import cn.gailvlun.gll.net.apartment.room.Task;



public class TaskSettingAdapter extends SingleTypeAdapter<Task> {
    public TaskSettingAdapter(Context context) {
        super(context, R.layout.item_task_setting);
    }

    public boolean isComplete() {
        for (Task task:
             mCollection) {
            if (task.getId() == null) {
                return false;
            }
        }
        return true;
    }

    public int indexId(int id) {
        for (int i = 0; i < mCollection.size(); i++) {
            if (mCollection.get(i).getId() != null && mCollection.get(i).getId() == id) {
                return i;
            }
        }
        return -1;
    }

    public ArrayList<Integer> getIdList() {
        ArrayList<Integer> idList = new ArrayList<>();
        for (Task task :
                mCollection) {
            if (task.getId() != null) {
                idList.add(task.getId());
            }
        }
        return idList;
    }

    public List<Task> getData() {
        return mCollection;
    }
}
